﻿namespace OutLook.Module.Load
{
    using System;
    using OutLook.Model.Domains;
    using OutLook.Module.Infrastructure;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class LoadStorage : XmlRepository
    {
        #region Constructors

        private LoadStorage() { }

        #endregion

        #region Properties

        /// <summary>
        /// Gets instance of LoadStorage
        /// </summary>
        public static LoadStorage Instance
        {
            get
            {
                lock (__mutex)
                {
                    if (m_LoadXmlRepository == null)
                        m_LoadXmlRepository = new LoadStorage();

                    return m_LoadXmlRepository;
                }
            }
        }

        #endregion

        #region Methods

        public override T Create<T>()
        {
            if (typeof(T) == typeof(Load))
                return new Load() as T;

            if (typeof(T) == typeof(LoadData))
                return LoadData.Create() as T;

            if (typeof(T) == typeof(User))
                return new User() as T;

            throw new NotSupportedException(ModuleConstants.NOT_SUPPORTED_TYPE_EXCEPTION);
        }

        public override bool AnalysisResults()
        {
            throw new NotImplementedException();
        }

        protected override void LoadTestData()
        {
            throw new NotImplementedException();
        }
        
        #endregion        

        #region Private Fields

        private static LoadStorage m_LoadXmlRepository = default(LoadStorage);
        private readonly static object __mutex = new object();

        #endregion
    }
}
